﻿using System;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.Runtime.Serialization;
using System.Xml;
using System.ServiceModel.Channels;
using System.Diagnostics;
using System.IO;
using System.Xml.Schema;
using System.ServiceModel.Description;
using Microsoft.MSE.Catalog.Contracts;
using Microsoft.MSE.Catalog.Contracts.Messages;
using Microsoft.MSE.Catalog.Contracts.Services;
using MSEContracts = Microsoft.MSE.Catalog.Contracts;
using Bus = Microsoft.MSE.Catalog.Module.Business;
using Microsoft.MSE.Catalog.Module;

namespace Microsoft.MSE.Catalog.Module.Services
{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, AddressFilterMode = AddressFilterMode.Any)]
    public class ServiceModel : IServiceModel, IChangeNotificationService
    {
        private ISubscriptionManager _subscriptionManager;
        private INotificationManager _notificationManager;
        private object _eventingLock = new object();

        public ServiceModel(Uri baseAddress)
        {
        }

        private ISubscriptionManager Subscriptions
        {
            get
            {
                if (_subscriptionManager != null)
                    return _subscriptionManager;
                lock (_eventingLock)
                {
                    if (_subscriptionManager != null)
                        return _subscriptionManager;
                    //try to obtain reference registered as an Extension before defaulting to our own implmenetation
                    _subscriptionManager = OperationContext.Current.Host.Extensions.Find<ISubscriptionManager>();
                    if (_subscriptionManager == null)
                        _subscriptionManager = new SubscriptionManager();
                    return _subscriptionManager;
                }
            }
        }
        private INotificationManager Notifications
        {
            get
            {
                if (_notificationManager != null)
                    return _notificationManager;
                lock (_eventingLock)
                {
                    if (_notificationManager != null)
                        return _notificationManager;
                    //try to obtain reference registered as an Extension before defaulting to our own implmenetation
                    _notificationManager = OperationContext.Current.Host.Extensions.Find<INotificationManager>();
                    if (_notificationManager == null)
                    {
                        //_notificationManager = new NotificationManager(this.Subscriptions);
                        //new notification manager that doesn't use subscription list
                        _notificationManager = new MSENotificationManager();
                    }
                    return _notificationManager;
                }
            }
        }

        #region Private Members
        private static MseEventData BuildNotificationData(DBEventContext dbNotification)
        {
            MseEventData mseEvent = new MseEventData(MapDbEventToEventTopics(dbNotification.Event, dbNotification.ChangeType));
            //fill out notification details;

            foreach (DBEventDataItem dbItem in dbNotification.EventData)
            {
                //Process RuntimeServer event data
                RuntimeServerEventData rsItem = mseEvent.RuntimeServers.Find(data => data.Id == dbItem.RuntimeServerId.ToString());

                if (rsItem == null)
                {
                    rsItem = new RuntimeServerEventData();
                    rsItem.Id = dbItem.RuntimeServerId.ToString();
                    mseEvent.RuntimeServers.Add(rsItem);
                }

                //Process Endpoint event data
                //move on to next dbItem if no endpoint id
                if (dbItem.EndpointId == Guid.Empty)
                    continue;
                EndpointEventData epItem = rsItem.Endpoints.Find(data => data.Id == dbItem.EndpointId.ToString());

                if (epItem == null)
                {
                    epItem = new EndpointEventData();
                    epItem.Id = dbItem.EndpointId.ToString();
                    rsItem.Endpoints.Add(epItem);
                }

                //Process Operation event data
                //move on to next dbItem if no operation id
                if (dbItem.OperationId == Guid.Empty)
                    continue;
                OperationEventData opItem = epItem.Operations.Find(data => data.Id == dbItem.OperationId.ToString());
                if (opItem == null)
                {
                    opItem = new OperationEventData();
                    opItem.Id = dbItem.OperationId.ToString();
                    epItem.Operations.Add(opItem);
                }
            }
            return mseEvent;
        }
        private static EventTopics MapDbEventToEventTopics(DBEvents item, DBChangeType changeType)
        {
            switch (item)
            {
                case DBEvents.RuntimeServersUpdated:
                    return EventTopics.RuntimeUpdated;
                case DBEvents.EndpointsUpdated:
                    switch (changeType)
                    {
                        case DBChangeType.Create:
                            return EventTopics.RuntimeEndpointAdded;
                        case DBChangeType.Delete:
                            return EventTopics.RuntimeEndpointRemoved;
                        default:
                            return EventTopics.RuntimeEndpointChanged;
                    }
                case DBEvents.OperationsUpdated:
                    return EventTopics.RuntimeEndpointOperationChanged;
                case DBEvents.EndpointOpAssociationUpdated:
                    switch (changeType)
                    {
                        case DBChangeType.Delete:
                            return EventTopics.RuntimeEndpointOperationDeActivated;
                        case DBChangeType.Create:
                            return EventTopics.RuntimeEndpointOperationActivated;
                        default:
                            return EventTopics.RuntimeEndpointOperationChanged;
                    }
                case DBEvents.EndpointOpPublicationUpdated:
                    switch (changeType)
                    {
                        case DBChangeType.Create:
                            return EventTopics.RuntimeEndpointOperationPublished;
                        case DBChangeType.Delete:
                            return EventTopics.RuntimeEndpointOperationUnPublished;
                        default:
                            return EventTopics.RuntimeEndpointOperationChanged;
                    }
                case DBEvents.RuntimeServersBindingUpdated:
                    return EventTopics.RuntimeBindingUpdated;
                case DBEvents.RuntimeServersPolicyUpdated:
                    return EventTopics.RuntimePolicyUpdated;
                default:
                    return EventTopics.RuntimeUpdated;
            }
        }
        #endregion

        #region MSEEventing Members

        public void AcceptEvent(AcceptEventMsg request)
        {

            if (request == null || request.AcceptEvent == null)
            {
                TraceHelper.TraceError("Invalid event notification received from DB.");
                return;
            }

            TraceHelper.TraceInformation("Event Notification for " + request.AcceptEvent.Event.ToString() + " received from DB");
            switch (request.AcceptEvent.Event)
            {
                case DBEvents.EndpointOpAssociationUpdated:
                case DBEvents.EndpointOpPublicationUpdated:
                case DBEvents.EndpointsUpdated:
                    try
                    {
                        MseEventData notificationData = BuildNotificationData(request.AcceptEvent);
                        Notifications.RaiseEvent(notificationData);
                        Dictionary<Guid, Guid> endpoints = new Dictionary<Guid, Guid>();
                        foreach (DBEventDataItem dbEventDataItem in request.AcceptEvent.EventData)
                        {
                            if (dbEventDataItem.EndpointId != Guid.Empty &&
                                endpoints.ContainsKey(dbEventDataItem.EndpointId) == false)
                            {
                                // This is disabled for now
                                //DAL.PublishEndPointToUddi(dbEventDataItem.EndpointId, false, null, null);
                                endpoints.Add(dbEventDataItem.EndpointId, dbEventDataItem.EndpointId);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        string msg = ex.Message;
                        //throw ex;
                    }
                    break;
                case DBEvents.OperationsUpdated:
                    try
                    {
                        MseEventData notificationData = BuildNotificationData(request.AcceptEvent);
                        Notifications.RaiseEvent(notificationData);
                    }
                    catch (Exception ex)
                    {
                        string msg = ex.Message;
                        //throw ex;
                    }
                    break;
                case DBEvents.RuntimeServersUpdated:
                case DBEvents.RuntimeServersBindingUpdated:
                case DBEvents.RuntimeServersPolicyUpdated:
                    try
                    {
                        MseEventData notificationData = BuildNotificationData(request.AcceptEvent);
                        Notifications.RaiseEvent(notificationData);
                        Dictionary<Guid, Guid> runtimeservers = new Dictionary<Guid, Guid>();
                        foreach (DBEventDataItem dbEventDataItem in request.AcceptEvent.EventData)
                        {
                            if (dbEventDataItem.RuntimeServerId != Guid.Empty &&
                                runtimeservers.ContainsKey(dbEventDataItem.RuntimeServerId) == false)
                            {
                                Bus.EndpointManager.PublishRuntimeServerEndPointsToUddi(dbEventDataItem.RuntimeServerId, false, null, null);
                                runtimeservers.Add(dbEventDataItem.RuntimeServerId, dbEventDataItem.RuntimeServerId);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        string msg = ex.Message;
                        //throw ex;
                    }
                    break;
                //case DBEvents.EndpointPolicyUpdated:
                //    sSubscriptionManager.RaiseEvent(Enum.GetName(request.AcceptEvent.Event.GetMSEType(), request.AcceptEvent.Event));
                //    break;
                //case DBEvents.ServiceDefinitionUpdated:
                //    sSubscriptionManager.RaiseEvent(Enum.GetName(request.AcceptEvent.Event.GetMSEType(), request.AcceptEvent.Event));
                //    break;
                //case DBEvents.ServicePolicyUpdated:
                //    sSubscriptionManager.RaiseEvent(Enum.GetName(request.AcceptEvent.Event.GetMSEType(), request.AcceptEvent.Event));
                //    break;
                default:
                    TraceHelper.TraceError("Unexpected notification event received [" + Enum.GetName(typeof(DBEvents), request.AcceptEvent.Event) + "]");
                    break;
            }
        }

        //public SubscribeResponseMsg Subscribe(SubscribeRequestMsg request)
        //{
        //    return new SubscribeResponseMsg(Subscriptions.Subscribe(request.Subscribe));
        //}

        //public RenewResponseMsg Renew(RenewRequestMsg request)
        //{
        //    if (request.ReferenceParameters == null) throw new WSEInvalidMessageFault(SC.CatalogSvcActor, "ReferenceParameters Header was not supplied");
        //    return new RenewResponseMsg(Subscriptions.Renew(request.Renew, request.ReferenceParameters));
        //}

        //public void Unsubscribe(UnsubscribeRequestMsg request)
        //{
        //    if (request.ReferenceParameters == null) throw new WSEInvalidMessageFault(SC.CatalogSvcActor, "ReferenceParameters Header was not supplied");
        //    Subscriptions.Unsubscribe(request.Unsubscribe, request.ReferenceParameters);
        //}

        //public GetStatusResponseMsg GetStatus(GetStatusRequestMsg request)
        //{
        //    if (request.ReferenceParameters == null) throw new WSEInvalidMessageFault(SC.CatalogSvcActor, "ReferenceParameters Header was not supplied");
        //    return new GetStatusResponseMsg(Subscriptions.GetStatus(request.GetStatus, request.ReferenceParameters));
        //}

        #endregion

        #region IWCFCatalogSvc Members

        #region Infrastructure Methods

        public Guid GetIDFromName(string entityName, EntityClass entityClass)
        {
            try
            {
                return Bus.EntityManager.GetIDFromName(entityName, entityClass, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Entity GetNameFromID(Guid entityID, EntityClass entityClass)
        {
            try
            {
                return Bus.EntityManager.GetNameFromID(entityID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        #endregion

        #region operation

        public GetOperationResponse GetOperation(GetOperationRequest request)
        {
            try
            {
                GetOperationResponse response = new GetOperationResponse();
                response.Operation = Bus.OperationManager.GetOperation(request.ID, null, null);
                return response;
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public OperationList ListOperations()
        {
            try
            {
                return Bus.OperationManager.ListOperations(null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public OperationList ListOperationsBySchema(Guid ID)
        {
            try
            {
                return Bus.OperationManager.ListOperationsBySchema(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public OperationList ListOperationsByResource(Guid ID)
        {
            try
            {
                return Bus.OperationManager.ListOperationsByResource(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Guid CreateOperation(Operation operation)
        {
            try
            {
                return Bus.OperationManager.CreateOperation(operation);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteOperation(Guid ID)
        {
            try
            {
                Bus.OperationManager.DeleteOperation(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Operation UpdateOperation(Operation operation)
        {
            try
            {
                return Bus.OperationManager.UpdateOperation(operation);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Operation GetOperation(Guid ID)
        {
            try
            {
                return Bus.OperationManager.GetOperation(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Guid GetIDForOperation(string entityName, string fqn)
        {
            try
            {
                return Bus.OperationManager.GetIDForOperation(entityName, fqn, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public OperationGroup CreateOperationGroup(OperationGroup operationGroup)
        {
            try
            {
                return Bus.OperationManager.CreateOperationGroup(operationGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public OperationGroup GetOperationGroup(Guid ID)
        {
            try
            {
                return Bus.OperationManager.GetOperationGroup(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteOperationGroup(Guid ID)
        {
            try
            {
                Bus.EntityManager.DeleteEntityGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public OperationGroup UpdateOperationGroup(OperationGroup operationGroup)
        {
            try
            {
                return Bus.OperationManager.UpdateOperationGroup(operationGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListEntityGroups()
        {
            try
            {
                return Bus.EntityManager.ListEntityGroups((int)EntityClass.Operation, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListEntityGroupsByOperation(Guid operationID)
        {
            try
            {
                return Bus.EntityManager.ListEntityGroupsByEntity(operationID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListOperationGroups()
        {
            try
            {
                return Bus.OperationManager.ListOperationGroups();
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListOperationGroupsByOperation(Guid operationID)
        {
            try
            {
                return Bus.OperationManager.ListOperationGroupsByOperation(operationID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public List<OperationListElement> ListOperationsByGroup(Guid ID)
        {
            try
            {
                return Bus.OperationManager.ListOperationsByGroup(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        #endregion

        #region operationVersion

        public Guid CreateOperationVersion(OperationVersion operationVersion)
        {
            try
            {
                return Bus.OperationManager.CreateOperationVersion(operationVersion, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteOperationVersion(Guid ID)
        {
            try
            {
                Bus.OperationManager.DeleteOperationVersion(ID, true, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public OperationVersion UpdateOperationVersion(OperationVersion operationVersion)
        {
            try
            {
                return Bus.OperationManager.UpdateOperationVersion(operationVersion, true, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public OperationVersion GetOperationVersion(Guid ID)
        {
            try
            {
                return Bus.OperationManager.GetOperationVersion(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        #endregion

        #region RuntimeServer

        public RuntimeServerList ListRuntimeServers()
        {
            try
            {
                return Bus.RuntimeServerManager.ListRuntimeServers(null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Guid CreateRuntimeServer(RuntimeServer runtimeServer)
        {
            try
            {
                return Bus.RuntimeServerManager.CreateRuntimeServer(runtimeServer, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteRuntimeServer(Guid ID)
        {
            try
            {
                Bus.RuntimeServerManager.DeleteRuntimeServer(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public RuntimeServer UpdateRuntimeServer(RuntimeServer runtimeServer)
        {
            try
            {
                return Bus.RuntimeServerManager.UpdateRuntimeServer(runtimeServer, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public RuntimeServer GetRuntimeServer(Guid ID)
        {
            try
            {
                return Bus.RuntimeServerManager.GetRuntimeServer(ID, true, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public RuntimeServer GetRuntimeServerWithoutEndpointWSDL(Guid ID)
        {
            try
            {
                return Bus.RuntimeServerManager.GetRuntimeServer(ID, false, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public RuntimeServer GetRuntimeServerByName(string name)
        {
            try
            {
                Guid ID = Bus.EntityManager.GetIDFromName(name, EntityClass.RuntimeServer, null, null);
                RuntimeServer rs = Bus.RuntimeServerManager.GetRuntimeServer(ID, true, null, null);
                SetPoliciesForRuntime(rs);
                return rs;
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public RuntimeServerGroup CreateRuntimeServerGroup(RuntimeServerGroup runtimeServerGroup)
        {
            try
            {
                return Bus.RuntimeServerManager.CreateRuntimeServerGroup(runtimeServerGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public RuntimeServerGroup GetRuntimeServerGroup(Guid ID)
        {
            try
            {
                return Bus.RuntimeServerManager.GetRuntimeServerGroup(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteRuntimeServerGroup(Guid ID)
        {
            try
            {
                Bus.EntityManager.DeleteEntityGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public RuntimeServerGroup UpdateRuntimeServerGroup(RuntimeServerGroup runtimeServerGroup)
        {
            try
            {
                return Bus.RuntimeServerManager.UpdateRuntimeServerGroup(runtimeServerGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListRuntimeServerGroups()
        {
            try
            {
                return Bus.EntityManager.ListEntityGroups((int)EntityClass.RuntimeServer, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListRuntimeServerGroupsByRuntimeServer(Guid runtimeServerID)
        {
            try
            {
                return Bus.EntityManager.ListEntityGroupsByEntity(runtimeServerID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public List<RuntimeServerListElement> ListRuntimeServersByGroup(Guid ID)
        {
            try
            {
                return Bus.RuntimeServerManager.ListRuntimeServersByGroup(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        #endregion

        #region Endpoint

        public EndpointList ListEndpoints()
        {
            try
            {
                return Bus.EndpointManager.ListEndpoints(null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EndpointList ListEndpointsForRuntimeServer(string runtimeServerName)
        {
            try
            {
                Guid runtimeServerID = Bus.EntityManager.GetIDFromName(runtimeServerName, EntityClass.RuntimeServer, null, null);
                return Bus.EndpointManager.ListEndpointsForRuntimeServerID(runtimeServerID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Guid CreateEndpoint(Endpoint endpoint)
        {
            try
            {
                return Bus.EndpointManager.CreateEndpoint(endpoint, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteEndpoint(Guid ID)
        {
            try
            {
                Bus.EndpointManager.DeleteEndpoint(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Endpoint UpdateEndpoint(Endpoint endpoint)
        {
            try
            {
                return Bus.EndpointManager.UpdateEndpoint(endpoint);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Endpoint GetEndpoint(Guid ID, Guid runtimeServerID)
        {
            try
            {
                return Bus.EndpointManager.GetEndpoint(ID, runtimeServerID, true, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Endpoint GetEndpointWithoutWSDL(Guid ID)
        {
            try
            {
                return Bus.EndpointManager.GetEndpoint(ID, Guid.Empty, false, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Guid GetIDForEndpoint(string name, int port, string scheme)
        {
            try
            {
                return Bus.EndpointManager.GetIDForEndpoint(name, port, scheme, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Endpoint GetEndpoint(string name, int port, string scheme)
        {
            try
            {
                Guid ID = Bus.EndpointManager.GetIDForEndpoint(name, port, scheme, null, null);
                return Bus.EndpointManager.GetEndpoint(ID, Guid.Empty, true, null, null);
            }
            catch (ApplicationException aex)
            {
                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void AssignAssociatedOperationVerToEndpoint(Guid operationVersionID, Guid endpointID)
        {
            try
            {
                Bus.OperationManager.AssignAssociatedOperationVersionToEndpoint(operationVersionID, endpointID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void AssignPublishedOperationVerToEndpoint(Guid operationVersionID, Guid endpointID)
        {
            try
            {
                Bus.OperationManager.AssignPublishedOperationVersionToEndpoint(operationVersionID, endpointID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void RemoveAssociatedOperationVerForEndpoint(Guid operationVersionID, Guid endpointID)
        {
            try
            {
                Bus.OperationManager.RemoveAssociatedOperationVersionFromEndpoint(operationVersionID, endpointID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void RemovePublishedOperationVerForEndpoint(Guid operationVersionID, Guid endpointID)
        {
            try
            {
                Bus.OperationManager.RemovePublishedOperationVersionFromEndpoint(operationVersionID, endpointID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EndpointGroup CreateEndpointGroup(EndpointGroup endpointGroup)
        {
            try
            {
                return Bus.EndpointManager.CreateEndpointGroup(endpointGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EndpointGroup GetEndpointGroup(Guid ID)
        {
            try
            {
                return Bus.EndpointManager.GetEndpointGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteEndpointGroup(Guid ID)
        {
            try
            {
                Bus.EntityManager.DeleteEntityGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EndpointGroup UpdateEndpointGroup(EndpointGroup endpointGroup)
        {
            try
            {
                return Bus.EndpointManager.UpdateEndpointGroup(endpointGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListEndpointGroups()
        {
            try
            {
                return Bus.EntityManager.ListEntityGroups((int)EntityClass.Endpoint, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListEndpointGroupsByEndpoint(Guid endpointID)
        {
            try
            {
                return Bus.EntityManager.ListEntityGroupsByEntity(endpointID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public List<EndpointListElement> ListEndpointsByGroup(Guid ID)
        {
            try
            {
                return Bus.EndpointManager.ListEndpointsByGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        #endregion

        #region Schema

        public SchemaList ListSchemas()
        {
            try
            {
                return Bus.SchemaManager.ListSchemas(null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Guid CreateSchema(Schema schema)
        {
            try
            {
                return Bus.SchemaManager.CreateSchema(schema);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Schema GetSchema(Guid ID)
        {
            try
            {
                return Bus.SchemaManager.GetSchema(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public List<Guid> ImportSchemas(List<Schema> importedSchemas)
        {
            try
            {
                return Bus.SchemaManager.ImportSchemas(importedSchemas);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Schema UpdateSchema(Schema schema)
        {
            try
            {
                //Schema oldSchema = Bus.SchemaManager.GetSchema(schema.ID, null, null);
                //List<string> errors = CompareSchemas(oldSchema, schema);

                //if (errors.Count > 0)
                //{
                //    string errMsg = "";
                //    foreach (string msg in errors)
                //    {
                //        errMsg += "  " + msg + ";";
                //    }
                //    throw new ApplicationException("Can not update Schema: ");
                //}

                return Bus.SchemaManager.UpdateSchema(schema, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void ValidateSchema(Schema schema)
        {
            try
            {
                Bus.SchemaManager.ValidateSchema(schema, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        private List<string> CompareSchemas(Schema oldSchemaObj, Schema newSchemaObj)
        { //string oldSchemaXML, string newSchemaXML) {
            try
            {
                List<string> result = new List<string>();
                XmlSchema oldSchema = XmlSchema.Read(new StringReader(oldSchemaObj.XSD.OuterXml), null);
                XmlSchema newSchema = XmlSchema.Read(new StringReader(newSchemaObj.XSD.OuterXml), null);

                // This is not necessary as both of these schemas have already been validated
                //XmlSchemaSet oldSchemaSet = new XmlSchemaSet();
                //XmlSchemaSet newSchemaSet = new XmlSchemaSet();
                //oldSchemaSet.Add(oldSchema);
                //newSchemaSet.Add(newSchema);
                //try {
                //    oldSchemaSet.Compile();
                //} catch (XmlSchemaException ex) {
                //    result.Add("Old schema is not valid: " + ex.Message);
                //    return result;
                //}
                //try {
                //    newSchemaSet.Compile();
                //} catch (XmlSchemaException ex) {
                //    result.Add("New schema is not valid: " + ex.Message);
                //    return result;
                //}

                XmlSchemaObjectTable oldElementTable = oldSchema.Elements;
                XmlSchemaObjectTable newElementTable = newSchema.Elements;

                foreach (XmlQualifiedName name in oldElementTable.Names)
                {
                    if (ElementInUse(oldSchemaObj.ID, name.Name))
                    {
                        XmlSchemaElement oldElement = (XmlSchemaElement)oldElementTable[name];
                        if (newElementTable.Contains(name))
                        {
                            XmlSchemaElement newElement = (XmlSchemaElement)newElementTable[name];
                            if (!oldElement.SchemaTypeName.Equals(newElement.SchemaTypeName))
                            {
                                result.Add(name.Name + " is of different type in new Schema");
                            }
                        }
                        else
                        {
                            result.Add(name.Name + " is missing from new Schema");
                        }
                    }
                }

                return result;
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public List<Schema> ListSchemasForExport(List<Entity> entities)
        {
            try
            {
                return Bus.SchemaManager.ListSchemasForExport(entities);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void SaveSchemasFromImport(List<Schema> schemas)
        {
            try
            {
                Bus.SchemaManager.SaveSchemasFromImport(schemas);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        private bool ElementInUse(Guid ID, string element)
        {
            try
            {
                bool result = false;
                OperationList operationList = Bus.OperationManager.ListOperationsByElement(ID, element, null, null);

                if ((operationList.Operations != null) && (operationList.Operations.Count > 0)) result = true;
                return result;
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        #region NZ Code Added for Schema Compare / Import

        public Guid ImportSchema(XmlElement schema, string preferredPrefix)
        {
            try
            {

                Schema newSchema;
                Schema oldSchema;
                XmlDocument xdoc = new XmlDocument();
                xdoc.LoadXml(schema.OuterXml);
                // NZ Code Added
                ClearImportNodeLocation(xdoc);
                XmlNamespaceManager xmlns = new XmlNamespaceManager(xdoc.NameTable);
                xmlns.AddNamespace("xs", XmlSchema.Namespace);
                string namespaceURI = xdoc.SelectSingleNode("/xs:schema/@targetNamespace", xmlns).Value;
                Guid id = Bus.EntityManager.GetIDFromName(namespaceURI, EntityClass.Schema, null, null);

                if (!id.Equals(Guid.Empty))
                {
                    oldSchema = Bus.SchemaManager.GetSchema(id, null, null);
                    XmlDocument xdoc2 = new XmlDocument();
                    xdoc2.LoadXml(oldSchema.XSD.OuterXml);

                    //xdoc = MergeSchemas(xdoc, xdoc2);
                    xdoc = MergeSchemaTypes(xdoc, xdoc2);

                    newSchema = new Schema();
                    newSchema.ID = id;
                    newSchema.NamespaceURI = namespaceURI;
                    newSchema.XSD = xdoc.DocumentElement;
                    //newSchema.PreferredPrefix = preferredPrefix;
                    return Bus.SchemaManager.UpdateSchema(newSchema, null, null).ID;
                }
                else
                {
                    newSchema = new Schema();
                    newSchema.NamespaceURI = namespaceURI;
                    newSchema.XSD = xdoc.DocumentElement;
                    //newSchema.PreferredPrefix = preferredPrefix;
                    return Bus.SchemaManager.CreateSchema(newSchema);
                }
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        private void ClearImportNodeLocation(XmlDocument schemaDoc)
        {
            XmlNamespaceManager xmlns = new XmlNamespaceManager(schemaDoc.NameTable);
            xmlns.AddNamespace("xsd", XmlSchema.Namespace);
            XmlNodeList importNodes = schemaDoc.SelectNodes("//xsd:import", xmlns);
            foreach (XmlNode xn in importNodes)
            {
                if (xn.Attributes["schemaLocation"] != null)
                {
                    xn.Attributes.Remove(xn.Attributes["schemaLocation"]);
                }
            }
            string xml = schemaDoc.OuterXml;
        }
        
        private XmlDocument MergeSchemaTypes(XmlDocument schema1, XmlDocument schema2)
        {
            XmlSchema xs1 = null;
            XmlSchema xs2 = null;
            XmlSchemaSet xss1 = LoadSchemaFromXml(schema1, out xs1);
            XmlSchemaSet xss2 = LoadSchemaFromXml(schema2, out xs2);


            foreach (XmlQualifiedName xqn in xs2.AttributeGroups.Names)
            {
                if (xs1.AttributeGroups.Contains(xqn) == false)
                {
                    xs1.Items.Add(xs2.AttributeGroups[xqn]);
                }
                else
                {
                    WriteWarningForMatchingTypes(xqn, xs1.AttributeGroups[xqn], xs2.AttributeGroups[xqn]);
                }
            }
            foreach (XmlQualifiedName xqn in xs2.Attributes.Names)
            {
                if (xs1.Attributes.Contains(xqn) == false)
                {
                    xs1.Items.Add(xs2.Attributes[xqn]);
                }
                else
                {
                    WriteWarningForMatchingTypes(xqn, xs1.Attributes[xqn], xs2.Attributes[xqn]);
                }
            }
            foreach (XmlQualifiedName xqn in xs2.SchemaTypes.Names)
            {
                if (xs1.SchemaTypes.Contains(xqn) == false)
                {
                    xs1.Items.Add(xs2.SchemaTypes[xqn]);
                }
                else
                {
                    WriteWarningForMatchingTypes(xqn, xs1.SchemaTypes[xqn], xs2.SchemaTypes[xqn]);
                }
            }
            foreach (XmlQualifiedName xqn in xs2.Elements.Names)
            {
                if (xs1.Elements.Contains(xqn) == false)
                {
                    xs1.Items.Add(xs2.Elements[xqn]);
                }
                else
                {
                    WriteWarningForMatchingTypes(xqn, xs1.Elements[xqn], xs2.Elements[xqn]);
                }
            }
            string schemaXml = ConvertSchemaToXml(xs1);
            XmlDocument xdoc = new XmlDocument();
            xdoc.LoadXml(schemaXml);
            MergerSchemaImports(xdoc, schema2);

            return xdoc;
        }
        
        private void MergerSchemaImports(XmlDocument schemaDoc1, XmlDocument schemaDoc2)
        {
            XmlNamespaceManager xmlns = new XmlNamespaceManager(schemaDoc2.NameTable);
            xmlns.AddNamespace("xsd", XmlSchema.Namespace);
            XmlNodeList importNodes = schemaDoc2.SelectNodes("//xsd:import", xmlns);
            foreach (XmlNode xn in importNodes)
            {
                if (xn.Attributes != null && string.IsNullOrEmpty(xn.Attributes["namespace"].Value) == false)
                {
                    XmlElement xe = xn as XmlElement;
                    XmlElement xeImport = schemaDoc1.CreateElement(xe.Prefix, xe.LocalName, xe.NamespaceURI);
                    XmlAttribute xaNamespace = xeImport.Attributes.Append(schemaDoc1.CreateAttribute("namespace"));
                    xaNamespace.Value = xn.Attributes["namespace"].Value;
                    CatalogSvcHelper.AppendImportElementToSchema(schemaDoc1, xeImport);
                }
            }
        }
        
        private void WriteWarningForMatchingTypes(XmlQualifiedName xqn, XmlSchemaObject xso1, XmlSchemaObject xso2)
        {
            //string typeXml1 = SerializeSchemaO(xso1, xqn.Namespace);
            //string typeXml2 = SerializeSchemaElement(xso2, xqn.Namespace);
            //if (typeXml1.Equals(typeXml2))
            //{
            //    TraceHelper.TraceInformation("Ingoring second definition of type [{0}:{1}] as it is a duplicate of the first",xqn.Namespace,xqn.Name);
            //}
            //else
            //{
            //    TraceHelper.TraceWarning("Ingoring second definition of [{0}:{1}], however it may be defined differently: old definition [{2}] - new definition [{3}]", xqn.Namespace, xqn.Name,typeXml1,typeXml2);
            //}

        }
        
        private XmlSchemaSet LoadSchemaFromXml(XmlDocument schemaDoc, out XmlSchema xs)
        {
            XmlSchemaSet xss = new XmlSchemaSet();
            StringBuilder sbErrors = new StringBuilder();
            Dictionary<string, string> importHash = new Dictionary<string, string>();

            sbErrors.Append("");
            ValidationEventHandler vh = new ValidationEventHandler
            (
                delegate(object ob, ValidationEventArgs args)
                {
                    try
                    {
                        sbErrors.AppendFormat("Schema Validation Error: Exception[{0}] Message[{1}]", TraceHelper.GetExceptionDetails(args.Exception), args.Message);
                    }
                    catch (Exception ex)
                    {
                        sbErrors.AppendFormat("Failed to Validate Schema due to error [{0}]", TraceHelper.GetExceptionDetails(ex));
                    }
                }
            );

            xs = XmlSchema.Read(new StringReader(schemaDoc.OuterXml), vh);
            if (sbErrors.ToString().Length > 0)
            {
                xs = null;
                throw new ApplicationException(string.Format("Invalid schema XML [{0}] Error while loading [{1}]", schemaDoc.OuterXml, sbErrors.ToString()));
            }
            xss.Add(xs);
            importHash.Add(xs.TargetNamespace, xs.TargetNamespace);
            Bus.SchemaManager.LoadImportedSchemas(xss, importHash, schemaDoc, null, null);
            xss.Compile();
            return xss;
        }

        private string ConvertSchemaToXml(XmlSchema schema)
        {
            StringBuilder sb = new StringBuilder();
            XmlWriter xw = XmlWriter.Create(sb);
            schema.Write(xw);
            xw.Flush();
            return sb.ToString();
        }
        
        #endregion

        private XmlDocument MergeSchemas(XmlDocument schema1, XmlDocument schema2)
        {
            XmlNamespaceManager xmlns = new XmlNamespaceManager(schema1.NameTable);
            xmlns.AddNamespace("xsd", XmlSchema.Namespace);

            foreach (XmlNode node in schema2.SelectNodes("/xsd:schema/child::*", xmlns))
            {
                bool skip = false;
                foreach (XmlNode node2 in schema1.SelectNodes("/xsd:schema/xsd:" + node.LocalName, xmlns))
                {
                    string name1 = null;
                    string name2 = null;
                    if (node.Attributes["name"] != null) name1 = node.Attributes["name"].Value;
                    if (node2.Attributes["name"] != null) name2 = node2.Attributes["name"].Value;
                    if ((!string.IsNullOrEmpty(name1)) && (!string.IsNullOrEmpty(name2)) && (name1.Equals(name2)))
                    { // same "element", is it different
                        skip = true;
                        if (node.InnerXml.Equals(node2.InnerXml))
                        {
                            TraceHelper.TraceInformation("Ingoring second definition of " + node.Name + " " + name1 + " as it is a duplicate of the first");
                        }
                        else
                        {
                            string oldDef = node.InnerXml;
                            string newDef = node2.InnerXml;
                            TraceHelper.TraceWarning("Ingoring second definition of " + node.Name + " " + name1 + ", however it may be defined differently: old definition [{0}] - new definition [{1}]", oldDef, newDef);
                        }
                    }
                }
                if (!skip)
                {
                    XmlElement xl = node as XmlElement;
                    if (xl != null)
                    {
                        XmlNode nxl = schema1.CreateElement(xl.Prefix, xl.LocalName, xl.NamespaceURI);
                        foreach (XmlAttribute xattr in xl.Attributes)
                        {
                            XmlAttribute nxattr = schema1.CreateAttribute(xattr.Prefix, xattr.LocalName, xattr.NamespaceURI);
                            nxattr.Value = xattr.Value;
                            nxl.Attributes.Append(nxattr);
                        }
                        nxl.InnerXml = xl.InnerXml;
                        if (string.Compare(nxl.LocalName, "import", false) == 0 &&
                            string.Compare(nxl.NamespaceURI, XmlSchema.Namespace, true) == 0)
                        {
                            // It is import node so it should be at the very beginning
                            CatalogSvcHelper.AppendImportElementToSchema(schema1, nxl);
                        }
                        else
                        {
                            schema1.SelectSingleNode("/xsd:schema", xmlns).AppendChild(nxl);
                        }
                    }
                }
            }

            return schema1;
        }

        public void DeleteSchema(Guid ID)
        {
            try
            {
                Bus.SchemaManager.DeleteSchema(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public SchemaGroup CreateSchemaGroup(SchemaGroup schemaGroup)
        {
            try
            {
                return Bus.SchemaManager.CreateSchemaGroup(schemaGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public SchemaGroup GetSchemaGroup(Guid ID)
        {
            try
            {
                return Bus.SchemaManager.GetSchemaGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteSchemaGroup(Guid ID)
        {
            try
            {
                Bus.EntityManager.DeleteEntityGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public SchemaGroup UpdateSchemaGroup(SchemaGroup schemaGroup)
        {
            try
            {
                return Bus.SchemaManager.UpdateSchemaGroup(schemaGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListSchemaGroups()
        {
            try
            {
                return Bus.EntityManager.ListEntityGroups((int)EntityClass.Schema, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListSchemaGroupsBySchema(Guid schemaID)
        {
            try
            {
                return Bus.EntityManager.ListEntityGroupsByEntity(schemaID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public List<SchemaListElement> ListSchemasByGroup(Guid ID)
        {
            try
            {
                return Bus.SchemaManager.ListSchemasByGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        #endregion

        #region SchemaObject

        public void UpdateSchemaObjectReferences(List<Guid> oldSchemaObjectIDs, Guid newSchemaObjectID, bool removeOldVersion)
        {
            try
            {
                Bus.SchemaManager.UpdateSchemaObjectReferences(oldSchemaObjectIDs, newSchemaObjectID, removeOldVersion, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public List<SchemaObject> ListSchemaObjectDependencies(Guid ID)
        {
            try
            {
                return Bus.SchemaManager.ListSchemaObjectDependencies(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public List<Entity> ListSchemaObjectReferences(Guid ID)
        {
            try
            {
                return Bus.SchemaManager.ListSchemaObjectReferences(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public List<SchemaObject> ListSchemaObjectByNameTypeAndNamespace(string namespaceUri, string name, SchemaObjectType type)
        {
            try
            {
                return Bus.SchemaManager.ListSchemaObjectByNameTypeAndNamespace(namespaceUri, name, type);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public SchemaObject GetSchemaObjectByNameTypeAndNamespace(string namespaceUri, string name, SchemaObjectType type)
        {
            try
            {
                return Bus.SchemaManager.GetSchemaObjectByNameTypeAndNamespace(namespaceUri, name, type);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public SchemaObject GetSchemaObjectByID(Guid schemaObjectID)
        {
            try
            {
                return Bus.SchemaManager.GetSchemaObjectByID(schemaObjectID, true);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public SchemaObject GetEquivalentSchemaObject(SchemaObject schemaObject)
        {
            try
            {
                bool hasItems = false;
                return Bus.SchemaManager.GetEquivalentSchemaObject(schemaObject, ref hasItems, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        #endregion

        #region DataEntity

        public MSEContracts.DataEntity CreateDataEntity(MSEContracts.DataEntity dataEntity)
        {
            try
            {
                dataEntity.Name = Data.DataEntity.BuildDataEntityName(dataEntity);
                Guid dataEntityID = Data.Entity.GetIDFromName(dataEntity.Name, EntityClass.DataEntity, null, null);
                if (dataEntityID == Guid.Empty)
                {
                    return Bus.DataEntityManager.CreateDataEntity(dataEntity, null, null, true);
                }
                else
                {
                    return Bus.DataEntityManager.UpdateDataEntity(dataEntity, null, null, true);
                }

            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteDataEntity(Guid ID)
        {
            try
            {
                Bus.DataEntityManager.DeleteDataEntity(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSEContracts.DataEntity UpdateDataEntity(MSEContracts.DataEntity dataEntity)
        {
            try
            {
                return Bus.DataEntityManager.UpdateDataEntity(dataEntity, null, null, true);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSEContracts.DataEntity GetDataEntity(Guid ID)
        {
            try
            {
                return Bus.DataEntityManager.GetDataEntity(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public DataEntityList ListDataEntities()
        {
            try
            {
                return Bus.DataEntityManager.ListDataEntities();
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public List<DataEntityListElement> ListDataEntitiesByGroup(Guid ID)
        {
            try
            {
                return Bus.DataEntityManager.ListDataEntitiesByGroup(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public DataEntityGroup CreateDataEntityGroup(DataEntityGroup dataEntityGroup)
        {
            try
            {
                return Bus.DataEntityManager.CreateDataEntityGroup(dataEntityGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public DataEntityGroup GetDataEntityGroup(Guid ID)
        {
            try
            {
                return Bus.DataEntityManager.GetDataEntityGroup(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteDataEntityGroup(Guid ID)
        {
            try
            {
                Bus.EntityManager.DeleteEntityGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public DataEntityGroup UpdateDataEntityGroup(DataEntityGroup dataEntityGroup)
        {
            try
            {
                return Bus.DataEntityManager.UpdateDataEntityGroup(dataEntityGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListDataEntityGroups()
        {
            try
            {
                return Bus.EntityManager.ListEntityGroups((int)EntityClass.DataEntity, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListDataEntityGroupsByDataEntity(Guid dataEntityID)
        {
            try
            {
                return Bus.EntityManager.ListEntityGroupsByEntity(dataEntityID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        #endregion        
              
        #region MSEBinding

        public MSEBindingList ListMSEBindings()
        {
            try
            {
                return Bus.BindingManager.ListMSEBindings(null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Guid CreateMSEBinding(MSEBinding binding)
        {
            try
            {
                return Bus.BindingManager.CreateMSEBinding(binding);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteMSEBinding(Guid ID)
        {
            try
            {
                Bus.BindingManager.DeleteMSEBinding(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSEBinding UpdateMSEBinding(MSEBinding binding)
        {
            try
            {
                return Bus.BindingManager.UpdateMSEBinding(binding);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSEBinding GetMSEBinding(Guid ID)
        {
            try
            {
                return Bus.BindingManager.GetMSEBinding(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void AssignBindingElementsToBinding(Guid bindingID, Guid bindingElementID, int elementOrder)
        {
            try
            {
                Bus.BindingManager.AssignBindingElementsToBinding(bindingID, bindingElementID, elementOrder, null, null);

            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void RemoveBindingElementsFromBinding(Guid bindingID, Guid bindingElementID, int elementOrder)
        {
            try
            {
                Bus.BindingManager.RemoveBindingElementsFromBinding(bindingID, bindingElementID, elementOrder, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSEBindingGroup CreateMSEBindingGroup(MSEBindingGroup mseBindingGroup)
        {
            try
            {
                return Bus.BindingManager.CreateMSEBindingGroup(mseBindingGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSEBindingGroup GetMSEBindingGroup(Guid ID)
        {
            try
            {
                return Bus.BindingManager.GetMSEBindingGroup(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteMSEBindingGroup(Guid ID)
        {
            try
            {
                Bus.EntityManager.DeleteEntityGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSEBindingGroup UpdateMSEBindingGroup(MSEBindingGroup mseBindingGroup)
        {
            try
            {
                return Bus.BindingManager.UpdateMSEBindingGroup(mseBindingGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListMSEBindingGroups()
        {
            try
            {
                return Bus.EntityManager.ListEntityGroups((int)EntityClass.Binding, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListMSEBindingGroupsByMSEBinding(Guid mseBindingID)
        {
            try
            {
                return Bus.EntityManager.ListEntityGroupsByEntity(mseBindingID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public List<MSEBindingListElement> ListMSEBindingsByGroup(Guid ID)
        {
            try
            {
                return Bus.BindingManager.ListMSEBindingsByGroup(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        #endregion

        #region BindingElement

        public Guid CreateMSEBindingElement(MSEBindingElement bindingElement)
        {
            try
            {
                return Bus.BindingManager.CreateMSEBindingElement(bindingElement, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSEBindingElement UpdateMSEBindingElement(MSEBindingElement bindingElement)
        {
            try
            {
                return Bus.BindingManager.UpdateMSEBindingElement(bindingElement, null, null);

            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteMSEBindingElement(Guid ID)
        {
            try
            {
                Bus.BindingManager.DeleteMSEBindingElement(ID, null, null);

            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSEBindingElement GetMSEBindingElement(Guid ID)
        {
            try
            {
                return Bus.BindingManager.GetMSEBindingElement(ID, null, null);

            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSEBindingElementList ListMSEBindingElements()
        {
            try
            {
                return Bus.BindingManager.ListMSEBindingElements(null, null);

            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        #endregion

        #region Policy

        public PolicyList ListPolicies()
        {
            try
            {
                return Bus.PolicyManager.ListPolicies(null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Guid CreatePolicy(Policy policy)
        {
            try
            {
                return Bus.PolicyManager.CreatePolicy(policy, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeletePolicy(Guid ID)
        {
            try
            {
                Bus.PolicyManager.DeletePolicy(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Policy UpdatePolicy(Policy policy)
        {
            try
            {
                return Bus.PolicyManager.UpdatePolicy(policy, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Guid GetIDForPolicy(string entityName, EntityClass entityClass)
        {
            try
            {
                return Bus.PolicyManager.GetIDForPolicy(entityName, entityClass, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Policy GetPolicy(Guid ID)
        {
            try
            {
                return Bus.PolicyManager.GetPolicy(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public PolicyGroup CreatePolicyGroup(PolicyGroup policyGroup)
        {
            try
            {
                return Bus.PolicyManager.CreatePolicyGroup(policyGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public PolicyGroup GetPolicyGroup(Guid ID)
        {
            try
            {
                return Bus.PolicyManager.GetPolicyGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeletePolicyGroup(Guid ID)
        {
            try
            {
                Bus.EntityManager.DeleteEntityGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public PolicyGroup UpdatePolicyGroup(PolicyGroup policyGroup)
        {
            try
            {
                return Bus.PolicyManager.UpdatePolicyGroup(policyGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListPolicyGroups()
        {
            try
            {
                return Bus.EntityManager.ListEntityGroups((int)EntityClass.Policy, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListPolicyGroupsByPolicy(Guid policyID)
        {
            try
            {
                return Bus.EntityManager.ListEntityGroupsByEntity(policyID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public List<PolicyListElement> ListPolicysByGroup(Guid ID)
        {
            try
            {
                return Bus.PolicyManager.ListPoliciesByGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void AssignPolicyAssertionToPolicy(Guid policyID, Guid policyAssertionID, int assertionOrder)
        {
            try
            {
                Bus.PolicyManager.AssignPolicyAssertionToPolicy(policyID, policyAssertionID, assertionOrder, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void RemovePolicyAssertionFromPolicy(Guid policyID, Guid policyAssertionID)
        {
            try
            {
                Bus.PolicyManager.RemovePolicyAssertionFromPolicy(policyID, policyAssertionID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        #endregion

        #region Assertion        

        public Guid CreatePolicyAssertion(PolicyAssertion policyAssertion)
        {
            try
            {
                return Bus.PolicyManager.CreatePolicyAssertion(policyAssertion, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeletePolicyAssertion(Guid ID)
        {
            try
            {
                Bus.PolicyManager.DeletePolicyAssertion(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public PolicyAssertion UpdatePolicyAssertion(PolicyAssertion policyAssertion)
        {
            try
            {
                return Bus.PolicyManager.UpdatePolicyAssertion(policyAssertion, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public PolicyAssertion GetPolicyAssertion(Guid ID)
        {
            try
            {
                return Bus.PolicyManager.GetPolicyAssertion(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public PolicyAssertionList ListPolicyAssertions()
        {
            try
            {
                return Bus.PolicyManager.ListPolicyAssertions(null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public PolicyAssertionList ListPolicyAssertionsByPolicy(Guid policyID)
        {
            try
            {
                return Bus.PolicyManager.ListPolicyAssertionsByPolicy(policyID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public PolicyAssertionGroup CreatePolicyAssertionGroup(PolicyAssertionGroup policyAssertionGroup)
        {
            try
            {
                return Bus.PolicyManager.CreatePolicyAssertionGroup(policyAssertionGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public PolicyAssertionGroup GetPolicyAssertionGroup(Guid ID)
        {
            try
            {
                return Bus.PolicyManager.GetPolicyAssertionGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeletePolicyAssertionGroup(Guid ID)
        {
            try
            {
                Bus.EntityManager.DeleteEntityGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public PolicyAssertionGroup UpdatePolicyAssertionGroup(PolicyAssertionGroup policyAssertionGroup)
        {
            try
            {
                return Bus.PolicyManager.UpdatePolicyAssertionGroup(policyAssertionGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListPolicyAssertionGroups()
        {
            try
            {
                return Bus.EntityManager.ListEntityGroups((int)EntityClass.PolicyAssertion, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListPolicyAssertionGroupsByPolicyAssertion(Guid policyAssertionID)
        {
            try
            {
                return Bus.EntityManager.ListEntityGroupsByEntity(policyAssertionID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public List<PolicyAssertionListElement> ListPolicyAssertionsByGroup(Guid ID)
        {
            try
            {
                return Bus.PolicyManager.ListPolicyAssertionsByGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        #endregion

        #region AssertionType

        public Guid CreateAssertionType(AssertionType assertionType)
        {
            try
            {
                return Bus.PolicyManager.CreateAssertionType(assertionType, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteAssertionType(Guid ID)
        {
            try
            {
                Bus.PolicyManager.DeleteAssertionType(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public AssertionType UpdateAssertionType(AssertionType assertionType)
        {
            try
            {
                return Bus.PolicyManager.UpdateAssertionType(assertionType, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public AssertionType GetAssertionType(Guid ID)
        {
            try
            {
                return Bus.PolicyManager.GetAssertionType(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public AssertionTypeList ListAssertionType()
        {
            try
            {
                return Bus.PolicyManager.ListAssertionType(null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void AssignSubjectToAssertionType(EntityClass entityClass, Guid assertionTypeID)
        {
            try
            {
                Bus.PolicyManager.AssignSubjectToAssertionType(entityClass, assertionTypeID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void RemoveAllSubjectsFromAssertionType(Guid assertionTypeID)
        {
            try
            {
                Bus.PolicyManager.RemoveAllSubjectsFromAssertionType(assertionTypeID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityClass[] GetAssertionTypeSubjects(Guid assertionTypeID)
        {
            try
            {
                return Bus.PolicyManager.GetAssertionTypeSubjects(assertionTypeID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public AssertionTypeGroup CreateAssertionTypeGroup(AssertionTypeGroup assertionTypeGroup)
        {
            try
            {
                return Bus.PolicyManager.CreateAssertionTypeGroup(assertionTypeGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public AssertionTypeGroup GetAssertionTypeGroup(Guid ID)
        {
            try
            {
                return Bus.PolicyManager.GetAssertionTypeGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteAssertionTypeGroup(Guid ID)
        {
            try
            {
                Bus.EntityManager.DeleteEntityGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public AssertionTypeGroup UpdateAssertionTypeGroup(AssertionTypeGroup assertionTypeGroup)
        {
            try
            {
                return Bus.PolicyManager.UpdateAssertionTypeGroup(assertionTypeGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListAssertionTypeGroups()
        {
            try
            {
                return Bus.EntityManager.ListEntityGroups((int)EntityClass.AssertionType, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListAssertionTypeGroupsByAssertionType(Guid assertionTypeID)
        {
            try
            {
                return Bus.EntityManager.ListEntityGroupsByEntity(assertionTypeID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public List<AssertionTypeListElement> ListAssertionTypesByGroup(Guid ID)
        {
            try
            {
                return Bus.PolicyManager.ListAssertionTypesByGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        #endregion

        #region MSESystem

        public Guid CreateMSESystem(MSEContracts.MSESystem system)
        {
            try
            {
                return Bus.MSESystemsManager.CreateMSESystem(system, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteMSESystem(Guid ID)
        {
            try
            {
                Bus.MSESystemsManager.DeleteMSESystem(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSEContracts.MSESystem UpdateMSESystem(MSEContracts.MSESystem system)
        {
            try
            {
                return Bus.MSESystemsManager.UpdateMSESystem(system, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Guid GetIDForMSESystem(string entityName, string uri)
        {
            try
            {
                return Bus.MSESystemsManager.GetIDForMSESystem(entityName, uri, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSEContracts.MSESystem GetMSESystem(Guid ID)
        {
            try
            {
                return Bus.MSESystemsManager.GetMSESystem(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSESystemList ListMSESystems()
        {
            try
            {
                return Bus.MSESystemsManager.ListMSESystems( null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public List<MSESystemListElement> ListMSESystemsByGroup(Guid ID)
        {
            try
            {
                return Bus.MSESystemsManager.ListSystemsByGroup(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSESystemGroup CreateMSESystemGroup(MSESystemGroup systemGroup)
        {
            try
            {
                return Bus.MSESystemsManager.CreateSystemGroup(systemGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSESystemGroup GetMSESystemGroup(Guid ID)
        {
            try
            {
                return Bus.MSESystemsManager.GetSystemGroup(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteMSESystemGroup(Guid ID)
        {
            try
            {
                Bus.EntityManager.DeleteEntityGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSESystemGroup UpdateMSESystemGroup(MSESystemGroup systemGroup)
        {
            try
            {
                return Bus.MSESystemsManager.UpdateSystemGroup(systemGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListMSESystemGroups()
        {
            try
            {
                return Bus.EntityManager.ListEntityGroups((int)EntityClass.System, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListMSESystemGroupsByMSESystem(Guid systemID)
        {
            try
            {
                return Bus.EntityManager.ListEntityGroupsByEntity(systemID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        #endregion

        #region SystemInstance

        public Guid CreateSystemInstance(MSEContracts.SystemInstance systemInstance)
        {
            try
            {
                return Bus.MSESystemsManager.CreateSystemInstance(systemInstance, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteSystemInstance(Guid ID)
        {
            try
            {
                Bus.MSESystemsManager.DeleteSystemInstance(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSEContracts.SystemInstance UpdateSystemInstance(MSEContracts.SystemInstance systemInstance)
        {
            try
            {
                return Bus.MSESystemsManager.UpdateSystemInstance(systemInstance, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Guid GetIDForSystemInstance(string entityName, string uri, int port)
        {
            try
            {
                return Bus.MSESystemsManager.GetIDForSystemInstance(entityName, uri, port,null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSEContracts.SystemInstance GetSystemInstance(Guid ID)
        {
            try
            {
                return Bus.MSESystemsManager.GetSystemInstance(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public SystemInstanceList ListSystemInstances()
        {
            try
            {
                return Bus.MSESystemsManager.ListSystemInstances(null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public List<SystemInstanceListElement> ListSystemInstancesByGroup(Guid ID)
        {
            try
            {
                return Bus.MSESystemsManager.ListSystemInstancesByGroup(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public SystemInstanceGroup CreateSystemInstanceGroup(SystemInstanceGroup systemInstanceGroup)
        {
            try
            {
                return Bus.MSESystemsManager.CreateSystemInstanceGroup(systemInstanceGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public SystemInstanceGroup GetSystemInstanceGroup(Guid ID)
        {
            try
            {
                return Bus.MSESystemsManager.GetSystemInstanceGroup(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteSystemInstanceGroup(Guid ID)
        {
            try
            {
                Bus.EntityManager.DeleteEntityGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public SystemInstanceGroup UpdateSystemInstanceGroup(SystemInstanceGroup systemInstanceGroup)
        {
            try
            {
                return Bus.MSESystemsManager.UpdateSystemInstanceGroup(systemInstanceGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListSystemInstanceGroups()
        {
            try
            {
                return Bus.EntityManager.ListEntityGroups((int)EntityClass.SystemInstance, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListSystemInstanceGroupsBySystemInstance(Guid systemInstanceID)
        {
            try
            {
                return Bus.EntityManager.ListEntityGroupsByEntity(systemInstanceID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        #endregion

        #region Resource        

        public Guid CreateResource(Resource resource)
        {
            try
            {
                return Bus.MSESystemsManager.CreateResource(resource, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteResource(Guid ID)
        {
            try
            {
                Bus.MSESystemsManager.DeleteResource(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Resource UpdateResource(Resource resource)
        {
            try
            {
                return Bus.MSESystemsManager.UpdateResource(resource, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Guid GetIDForResource(string entityName, string scheme, string uri)
        {
            try
            {
                return Bus.MSESystemsManager.GetIDForResource(entityName, scheme, uri, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Resource GetResource(Guid ID)
        {
            try
            {
                return Bus.MSESystemsManager.GetResource(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public ResourceList ListResources()
        {
            try
            {
                return Bus.MSESystemsManager.ListResources(null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public List<ResourceListElement> ListResourcesByGroup(Guid ID)
        {
            try
            {
                return Bus.MSESystemsManager.ListResourcesByGroup(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public ResourceGroup CreateResourceGroup(ResourceGroup resourceGroup)
        {
            try
            {
                return Bus.MSESystemsManager.CreateResourceGroup(resourceGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public ResourceGroup GetResourceGroup(Guid ID)
        {
            try
            {
                return Bus.MSESystemsManager.GetResourceGroup(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteResourceGroup(Guid ID)
        {
            try
            {
                Bus.EntityManager.DeleteEntityGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public ResourceGroup UpdateResourceGroup(MSEContracts.ResourceGroup resourceGroup)
        {
            try
            {
                return Bus.MSESystemsManager.UpdateResourceGroup(resourceGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListResourceGroups()
        {
            try
            {
                return Bus.EntityManager.ListEntityGroups((int)EntityClass.Resource, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListResourceGroupsByResource(Guid resourceID)
        {
            try
            {
                return Bus.EntityManager.ListEntityGroupsByEntity(resourceID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void PublishRuntimeServerEndPointsToUddi(Guid ID, bool refresh)
        {
            try
            {
                Bus.EndpointManager.PublishRuntimeServerEndPointsToUddi(ID, refresh, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void RemoveRuntimeServerEndPointsFromUddi(Guid ID)
        {
            try
            {
                Bus.EndpointManager.RemoveRuntimeServerEndPointsFromUddi(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public bool IsUddiIntegrationEnabled()
        {
            try
            {
                if (Configurator.svcConfig.serviceCatalogUddi != null &&
                    Configurator.svcConfig.serviceCatalogUddi.UddiIntegrationMode == true)
                    return true;
                else
                    return false;
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        #endregion 

        #region Actor

        public Guid CreateActor(MSEContracts.Actor actor)
        {
            try
            {
                return Bus.CapabilityManager.CreateActor(actor, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteActor(Guid ID)
        {
            try
            {
                Bus.CapabilityManager.DeleteActor(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSEContracts.Actor UpdateActor(MSEContracts.Actor actor)
        {
            try
            {
                return Bus.CapabilityManager.UpdateActor(actor, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }        

        public MSEContracts.Actor GetActor(Guid ID)
        {
            try
            {
                return Bus.CapabilityManager.GetActor(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void AssignCapabilityToActor(Guid capabilityID, Guid actorID, Guid sleID)
        {
            try
            {
                Bus.CapabilityManager.AssignCapabilityToActor(capabilityID, actorID, sleID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void RemoveCapabilityFromActor(Guid capabilityID, Guid actorID)
        {
            try
            {
                Bus.CapabilityManager.RemoveCapabilityFromActor(capabilityID, actorID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public ActorList ListActors()
        {
            try
            {
                return Bus.CapabilityManager.ListActors(null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public List<ActorListElement> ListActorsByGroup(Guid ID)
        {
            try
            {
                return Bus.CapabilityManager.ListActorsByGroup(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public ActorGroup CreateActorGroup(ActorGroup actorGroup)
        {
            try
            {
                return Bus.CapabilityManager.CreateActorGroup(actorGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public ActorGroup GetActorGroup(Guid ID)
        {
            try
            {
                return Bus.CapabilityManager.GetActorGroup(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteActorGroup(Guid ID)
        {
            try
            {
                Bus.EntityManager.DeleteEntityGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public ActorGroup UpdateActorGroup(ActorGroup actorGroup)
        {
            try
            {
                return Bus.CapabilityManager.UpdateActorGroup(actorGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListActorGroups()
        {
            try
            {
                return Bus.EntityManager.ListEntityGroups((int)EntityClass.Actor, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListActorGroupsByActor(Guid actorID)
        {
            try
            {
                return Bus.EntityManager.ListEntityGroupsByEntity(actorID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        #endregion

        #region Capability

        public Guid CreateCapability(MSEContracts.Capability capability)
        {
            try
            {
                return Bus.CapabilityManager.CreateCapability(capability, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteCapability(Guid ID)
        {
            try
            {
                Bus.CapabilityManager.DeleteCapability(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSEContracts.Capability UpdateCapability(MSEContracts.Capability capability)
        {
            try
            {
                return Bus.CapabilityManager.UpdateCapability(capability, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSEContracts.Capability GetCapability(Guid ID)
        {
            try
            {
                return Bus.CapabilityManager.GetCapability(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public CapabilityList ListCapabilities()
        {
            try
            {
                return Bus.CapabilityManager.ListCapabilities(null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public List<CapabilityListElement> ListCapabilitiesByGroup(Guid ID)
        {
            try
            {
                return Bus.CapabilityManager.ListCapabilitiesByGroup(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public CapabilityGroup CreateCapabilityGroup(CapabilityGroup capabilityGroup)
        {
            try
            {
                return Bus.CapabilityManager.CreateCapabilityGroup(capabilityGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public CapabilityGroup GetCapabilityGroup(Guid ID)
        {
            try
            {
                return Bus.CapabilityManager.GetCapabilityGroup(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteCapabilityGroup(Guid ID)
        {
            try
            {
                Bus.EntityManager.DeleteEntityGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public CapabilityGroup UpdateCapabilityGroup(CapabilityGroup capabilityGroup)
        {
            try
            {
                return Bus.CapabilityManager.UpdateCapabilityGroup(capabilityGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListCapabilityGroups()
        {
            try
            {
                return Bus.EntityManager.ListEntityGroups((int)EntityClass.Capability, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListCapabilityGroupsByCapability(Guid capabilityID)
        {
            try
            {
                return Bus.EntityManager.ListEntityGroupsByEntity(capabilityID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }
        
        public void AssignTypeToCapability(Guid capabilityID, Guid typeID, Boolean outputFlag)
        {
            try
            {
                Bus.CapabilityManager.AssignTypeToCapability(capabilityID, typeID, outputFlag, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void RemoveTypeFromCapability(Guid capabilityID, Guid typeID, Boolean outputFlag)
        {
            try
            {
                Bus.CapabilityManager.RemoveTypeFromCapability(capabilityID, typeID, outputFlag, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void AssignOperationToCapability(Guid capabilityID, Guid operationID)
        {
            try
            {
                Bus.CapabilityManager.AssignOperationToCapability(capabilityID, operationID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void RemoveOperationFromCapability(Guid capabilityID, Guid operationID)
        {
            try
            {
                Bus.CapabilityManager.RemoveOperationFromCapability(capabilityID, operationID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void AssignCapabilityToCapability(Guid parentCapabilityID, Guid childCapabilityID, Int16 order)
        {
            try
            {
                Bus.CapabilityManager.AssignCapabilityToCapability(parentCapabilityID, childCapabilityID, order, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void RemoveCapabilityFromCapability(Guid parentCapabilityID, Guid childCapabilityID, Int16 order)
        {
            try
            {
                Bus.CapabilityManager.RemoveCapabilityFromCapability(parentCapabilityID, childCapabilityID, order, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }


        #endregion

        #region MSEType

        public Guid CreateType(MSEContracts.MSEType type)
        {
            try
            {
                return Bus.CapabilityManager.CreateMSEType(type, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteType(Guid ID)
        {
            try
            {
                Bus.CapabilityManager.DeleteMSEType(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSEContracts.MSEType UpdateType(MSEContracts.MSEType type)
        {
            try
            {
                return Bus.CapabilityManager.UpdateMSEType(type, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSEContracts.MSEType GetType(Guid ID)
        {
            try
            {
                return Bus.CapabilityManager.GetMSEType(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void AssignDataEntityToType(Guid typeID, Guid dataEntityID)
        {
            try
            {
                Bus.CapabilityManager.AssignDataEntityToMSEType(typeID, dataEntityID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void RemoveDataEntityFromType(Guid typeID, Guid dataEntityID)
        {
            try
            {
                Bus.CapabilityManager.RemoveDataEntityFromMSEType(typeID, dataEntityID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSETypeList ListTypes()
        {
            try
            {
                return Bus.CapabilityManager.ListMSETypes(null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public List<MSETypeListElement> ListMSETypesByGroup(Guid ID)
        {
            try
            {
                return Bus.CapabilityManager.ListTypesByGroup(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSETypeGroup CreateMSETypeGroup(MSETypeGroup typeGroup)
        {
            try
            {
                return Bus.CapabilityManager.CreateTypeGroup(typeGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSETypeGroup GetMSETypeGroup(Guid ID)
        {
            try
            {
                return Bus.CapabilityManager.GetTypeGroup(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteMSETypeGroup(Guid ID)
        {
            try
            {
                Bus.EntityManager.DeleteEntityGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSETypeGroup UpdateMSETypeGroup(MSETypeGroup typeGroup)
        {
            try
            {
                return Bus.CapabilityManager.UpdateTypeGroup(typeGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListMSETypeGroups()
        {
            try
            {
                return Bus.EntityManager.ListEntityGroups((int)EntityClass.Type, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListMSETypeGroupsByMSEType(Guid typeID)
        {
            try
            {
                return Bus.EntityManager.ListEntityGroupsByEntity(typeID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        #endregion

        #region SLE

        public Guid CreateSLE(MSEContracts.SLE sLE)
        {
            try
            {
                return Bus.CapabilityManager.CreateSLE(sLE, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteSLE(Guid ID)
        {
            try
            {
                Bus.CapabilityManager.DeleteSLE(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSEContracts.SLE UpdateSLE(MSEContracts.SLE sLE)
        {
            try
            {
                return Bus.CapabilityManager.UpdateSLE(sLE, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSEContracts.SLE GetSLE(Guid ID)
        {
            try
            {
                return Bus.CapabilityManager.GetSLE(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public MSEContracts.SLE GetSLEForActorCapability(Guid actorID, Guid capabilityID)
        {
            try
            {
                return Bus.CapabilityManager.GetSLEForActorCapability(actorID, capabilityID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public SLEList ListSLEs()
        {
            try
            {
                return Bus.CapabilityManager.ListSLEs(null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public List<SLEListElement> ListSLEsByGroup(Guid ID)
        {
            try
            {
                return Bus.CapabilityManager.ListSLEsByGroup(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public SLEGroup CreateSLEGroup(SLEGroup sLEGroup)
        {
            try
            {
                return Bus.CapabilityManager.CreateSLEGroup(sLEGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public SLEGroup GetSLEGroup(Guid ID)
        {
            try
            {
                return Bus.CapabilityManager.GetSLEGroup(ID);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public void DeleteSLEGroup(Guid ID)
        {
            try
            {
                Bus.EntityManager.DeleteEntityGroup(ID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public SLEGroup UpdateSLEGroup(SLEGroup sLEGroup)
        {
            try
            {
                return Bus.CapabilityManager.UpdateSLEGroup(sLEGroup);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListSLEGroups()
        {
            try
            {
                return Bus.EntityManager.ListEntityGroups((int)EntityClass.SLE, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public EntityGroupList ListSLEGroupsBySLE(Guid sLEID)
        {
            try
            {
                return Bus.EntityManager.ListEntityGroupsByEntity(sLEID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        #endregion

        #endregion

        #region Runtime Methods

        public List<OperationVersion> GetOperationVersionsForEndpointAndAction(Guid endpointID, string action)
        {
            try
            {
                return Bus.OperationManager.GetOperationVersionsForEndpointAndAction(endpointID, action, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public List<OperationVersion> GetOperationVersionsForEndpointAndFirstBodyElement(Guid endpointID, string elementName, string namespaceURI)
        {
            try
            {
                return Bus.OperationManager.GetOperationVersionsForEndpointAndFirstBodyElement(endpointID, elementName, namespaceURI, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public Boolean ValidateOperationVersionRequest(XmlElement request, Guid opVersionID)
        {
            try
            {
                return Bus.OperationManager.ValidateOperationVersionRequest(request, opVersionID, null, null);
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public GetIDFromNameResponse GetIDFromName(GetIDFromNameRequest request)
        {
            try
            {
                GetIDFromNameResponse response = new GetIDFromNameResponse();
                response.ID = Bus.EntityManager.GetIDFromName(request.EntityName, request.EntityClass, null, null);
                return response;
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }        

        public GetOperationVersionsForEndpointAndActionResponse GetOperationVersionsForEndpointAndAction(GetOperationVersionsForEndpointAndActionRequest request)
        {
            try
            {
                GetOperationVersionsForEndpointAndActionResponse response = new GetOperationVersionsForEndpointAndActionResponse();
                response.OperationVersions = Bus.OperationManager.GetOperationVersionsForEndpointAndAction(request.EndpointID, request.Action, null, null);
                return response;
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public GetOperationVersionsForEndpointAndFirstBodyElementResponse GetOperationVersionsForEndpointAndFirstBodyElement(GetOperationVersionsForEndpointAndFirstBodyElementRequest request)
        {
            GetOperationVersionsForEndpointAndFirstBodyElementResponse response = new GetOperationVersionsForEndpointAndFirstBodyElementResponse();
            response.OperationVersions = GetOperationVersionsForEndpointAndFirstBodyElement(request.EndpointID, request.ElementName, request.NamespaceURI);
            return response;
        }

        public GetPolicyResponse GetPolicy(GetPolicyRequest request)
        {
            try
            {
                GetPolicyResponse response = new GetPolicyResponse();
                response.Policy = Bus.PolicyManager.GetPolicy(request.ID, null, null);
                return response;
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        private void SetPoliciesForRuntime(RuntimeServer rs)
        {
            if (rs.Policy == null) return;
            
            List<PolicyAssertion> endpointAssertions = new List<PolicyAssertion>();
            
            //Check and see if Runtime Serve has any endpoint policies
            foreach (PolicyAssertion assertion in rs.Policy.PolicyAssertions)
            {
                foreach (EntityClass subject in assertion.AssertionType.AssertionTypeSubjects)
                    if (subject == EntityClass.Endpoint)
                        endpointAssertions.Add(assertion);
            }

            //If endpoint assertions are NOT found in runtime server policy then do nothing
            if (endpointAssertions.Count == 0) return;

            foreach (PolicyAssertion assertion in endpointAssertions)
                rs.Policy.PolicyAssertions.Remove(assertion);

            //If end point assertions are found then remove then from runtime server policy and add it to each endpoint policy
            rs.Policy.WSPolicy = CatalogSvcHelper.GetPolicyXml(rs.Policy.PolicyAssertions);

            foreach (Endpoint ep in rs.Endpoints)
            {
                XmlDocument policyXML = new XmlDocument();

                if (ep.Policy != null)
                    policyXML.LoadXml(ep.Policy.WSPolicy.OuterXml); //Load existing policy
                else
                {
                    //Create a policy for the MSE runtime to use
                    policyXML.LoadXml(CatalogSvcHelper.policyModelXml); //Load policy model xml
                    ep.Policy = new Policy();
                    ep.Policy.EntityClass = EntityClass.Endpoint;
                    ep.Policy.Name = "Generated policy for Runtime";
                    ep.Policy.ID = Guid.Empty;
                    ep.Policy.PolicyAssertions = new List<PolicyAssertion>();
                }

                XmlNode destinationNode = policyXML.FirstChild as XmlNode;

                foreach (PolicyAssertion assertion in endpointAssertions)
                {
                    //How do we deal with assertion order?
                    ep.Policy.PolicyAssertions.Add(assertion);
                    destinationNode.AppendChild((policyXML.ImportNode(assertion.Assertion as XmlNode, true)));
                }

                ep.Policy.WSPolicy = policyXML.DocumentElement;
            }

        }

        public GetRuntimeServerByNameResponse GetRuntimeServerByName(GetRuntimeServerByNameRequest request)
        {
            try
            {
                GetRuntimeServerByNameResponse response = new GetRuntimeServerByNameResponse();
                Guid runtimeServerID = Bus.EntityManager.GetIDFromName(request.Name, MSEContracts.EntityClass.RuntimeServer, null, null);
                response.RuntimeServer = Bus.RuntimeServerManager.GetRuntimeServer(runtimeServerID, true, null, null);
                SetPoliciesForRuntime(response.RuntimeServer);
                return response;
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        public ValidateOperationVersionRequestResponse ValidateOperationVersionRequest(ValidateOperationVersionRequestRequest request)
        {
            try
            {
                ValidateOperationVersionRequestResponse response = new ValidateOperationVersionRequestResponse();
                response.IsValid = Bus.OperationManager.ValidateOperationVersionRequest(request.Request, request.OperationVersionID, null, null);
                return response;
            }
            catch (ApplicationException aex)
            {
                TraceHelper.TraceError("An application error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(aex));

                string subFaultCode = SC.DefaultSubFaultCode;

                if (aex.Data.Contains(SC.SubFaultCodeKey)) subFaultCode = aex.Data[SC.SubFaultCodeKey] as string;
                throw new FaultException(aex.Message, FaultCode.CreateReceiverFaultCode(new FaultCode(subFaultCode, MseConstants.MSENamespace)));
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("An unexpected error occurred in Catalog Service Operation [{0}]. Error Detail [{1}]", MethodInfo.GetCurrentMethod().Name, CatalogSvcHelper.GetExceptionDetails(ex));

                throw new FaultException(ex.Message, FaultCode.CreateSenderFaultCode(new FaultCode(SC.UnknownSubFaultCode, MseConstants.MSENamespace)));
            }
        }

        #endregion
    }


}
